#pragma once

#include "ExtensionPoint.h"

#include "UseCase.h"

namespace uml {

ExtensionPoint::ExtensionPoint(const QString& umlType)
    : NamedElement(umlType) {}

void ExtensionPoint::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    NamedElement::fromJson(json, errorList);
    RedefinableElement::fromJson(json, errorList);
    useCase_ = JsonSerializable::create<UseCase>(json.value("useCase"), errorList);

}

void ExtensionPoint::toJson(QJsonObject& json) {
    NamedElement::toJson(json);
    RedefinableElement::toJson(json);
    if (useCase_) {
        QJsonObject useCase_json;
        useCase_->toJson(useCase_json);
        json.insert("useCase", useCase_json);
    }
}

/// <summary>
/// useCase getter
/// The UseCase that owns this ExtensionPoint.
/// </summary>
shared_ptr<UseCase> ExtensionPoint::useCase() const {
    return useCase_;
}

/// <summary>
/// useCase setter
/// The UseCase that owns this ExtensionPoint.
/// </summary>
void ExtensionPoint::setUseCase(shared_ptr<UseCase> value) {
    useCase_ = value;
}

} // namespace uml
